<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('心愿单列表')" />
	<th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								用户ID：<input type="text" name="uid"/>
							</li>

							

						
							
							<li>心愿单类型：<select id="type" name="type" class="selectpicker show-tick "
					data-live-search="true" data-none-selected-text="请选择">
						<option></option>
						<option value=8003>小心愿单</option>
						<option value=8004>大心愿单</option>
				</select>
				</li>

						
							
						<!--	<li>助力进度：<select id="sffb" name="sffb" class="selectpicker show-tick "
					data-live-search="true" data-none-selected-text="请选择">
						<option></option>
						<option value="1">已开始助力</option>
						<option value="0">未开始助力</option>
				</select>
				</li>

							
							
							
							<li>状态：<select id="state" name="state" class="selectpicker show-tick "
					data-live-search="true" data-none-selected-text="请选择">
						<option></option>
						<option value="8100">未使用</option>
						<option value="8101">待处理</option>
						<option value="8102">审核成功</option>
						<option value="8103">审核失败</option>
						<option value="8104">助力失败</option>
						<option value="8105">未兑现心愿单</option>
						<option value="8106">已兑现心愿单</option>
				</select>
				</li>-->

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				
				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="SignWish:signWish:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <th:block th:include="include :: bootstrap-select-js" />
	<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('SignWish:signWish:edit')}]];
        var removeFlag = [[${@permission.hasPermi('SignWish:signWish:remove')}]];
        var prefix = ctx + "SignWish/signWish";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "心愿单",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '',
					visible: false
				},
				{
					field : 'uid', 
					title : '用户ID',
					sortable: true
				},
				
				
				
				{
					title: '图片',
				    formatter: function(value, row, index) {
				    	if($.common.isEmpty(row.tps)){
				    		return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png');
				    	} else {
				    		var imgs=row.tps;
				    		var result=imgs.split(",");
				    		var trueImg=result[0];
				    		return $.table.imageView(trueImg);
				    	}
				    }
					},
				
				
				
				
				
				{
					title: '心愿卡类型',
				    formatter: function(value, row, index) {
				    	if(row.type==8003){
				    		return "小心愿单";
				    	} else if(row.type==8004){
				    		return "大心愿单";
				    	} 
				    }
					},
				
				
				{
					title: '助力进度',
				    formatter: function(value, row, index) {
				    	if(row.sffb==1){
				    		return "已开始助力";
				    	} else if(row.sffb==0){
				    		return "未开始助力";
				    	} 
				    }
					},
				{
					field : 'createDate', 
					title : '创建时间',
					sortable: true
				},
				
				
				
				{
					title: '状态',
				    formatter: function(value, row, index) {
				    	if(row.state==8102){
				    		return "审核成功";
				    	} else if(row.state==8100){
							return "未使用";
						} else if(row.state==8101){
				    		return "待处理";
				    	} else if(row.state==8103){
				    		return "审核失败";
				    	} else if(row.state==8104){
				    		return "助力失败";
				    	} else if(row.state==8105){
				    		return "未兑现心愿单";
				    	} else if(row.state==8106){
				    		return "已兑现心愿单";
				    	}				    	
				    }
					},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="wishUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
		            	actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateStatus(\'' + row.id + '\')"><i class="fa fa-edit"></i>实现心愿</a> ');
		            	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateStatus2(\'' + row.id + '\')"><i class="fa fa-edit"></i>金币补偿</a> ');
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateStatus3(\'' + row.id + '\')"><i class="fa fa-edit"></i>优惠券补偿</a> ');
		            	actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateStatus4(\'' + row.id + '\')"><i class="fa fa-edit"></i>无补偿退回</a> ');
		            	//actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function wishUpdate(id) {
        	$.modal.open('心愿单详情', prefix + "/edit/" + id, '1300', '800');			
		}
        
        function updateStatus(id) {
			var days=prompt("请输入助力天数");
			var people=prompt("请输入助力人数");

			if(days==0||days==null||people==0||people==null){
				$.modal.alertWarning("助力天数及人数不可为空");
				return;
			} else {
				var url = prefix + "/updateStatus";
				var data = { "id": id , "days" : days , "people" : people};
				$.operate.submit(url, "post", "json", data);
			}
        }
        
        function updateStatus2(id) {
        	$.modal.confirm("是否确认退回心愿且进行金币补偿？", function() {
    			var url = prefix + "/updateStatus2";
    			var data = { "id": id };
        	    $.operate.submit(url, "post", "json", data);
    		});
        }
        
        function updateStatus3(id) {
        	$.modal.confirm("是否确认退回心愿且进行优惠券补偿？", function() {
    			var url = prefix + "/updateStatus3";
    			var data = { "id": id };
        	    $.operate.submit(url, "post", "json", data);
    		});
        }
        
        function updateStatus4(id) {
        	$.modal.confirm("是否确认退回心愿且无补偿？", function() {
    			var url = prefix + "/updateStatus4";
    			var data = { "id": id };
        	    $.operate.submit(url, "post", "json", data);
    		});
        }
        
        
    </script>
</body>
</html>